package view.toolboxComponents;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import controller.CustomEvent;
import controller.EventHandler;
import controller.ToolBoxEventHandler;
/** * A class to encapsulate the text colour changing panel on the designer * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
@SuppressWarnings("serial")
public class PrescriptionTextColourPanel extends AbstractPanel{
	private JLabel lblTextColour;
	private JButton btnTextColour;
	private EventHandler eventHandler;
	public PrescriptionTextColourPanel(){
		super();		
		btnTextColour = new JButton();
		btnTextColour.setPreferredSize(new Dimension(12,12));
		btnTextColour.setMaximumSize(new Dimension(12,12));
		btnTextColour.setToolTipText("Text colour");
		lblTextColour = new JLabel("Text Colour");
		buildPanel();
		//Changes the Text Colour inside the Box
		btnTextColour.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presTextColourChange", PrescriptionTextColourPanel.this);
				PrescriptionTextColourPanel.this.eventHandler = new ToolBoxEventHandler();
				PrescriptionTextColourPanel.this.eventHandler.createEvent(event);
			}
		});
	}
	/**
	 * Build prescription name panel
	 */
	private void buildPanel() {
		this.add(lblTextColour);
		makeRigidArea();
		this.add(btnTextColour);
	}
	@Override
	public void resetComponent() {
		btnTextColour.setBackground(null);
	}	/**	 * Sets the button background colour	 * @param c the {@link java.awt.Color} object to set as the colour of the button	 */
	public void setButtonBackgroundColour(Color c) {
		btnTextColour.setBackground(c);
	}
}